namespace Zj.HttpCodeDemo.ConsoleApp.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class initdb_Tables : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Users",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        UserName = c.String(nullable: false, maxLength: 16),
                        Password = c.String(nullable: false, maxLength: 32),
                        Age = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.UserLoginErrLogs",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        IPAddress = c.String(nullable: false, maxLength: 64),
                        LoginTime = c.DateTime(nullable: false),
                        UserId = c.Long(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Users", t => t.UserId, cascadeDelete: true)
                .Index(t => t.UserId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.UserLoginErrLogs", "UserId", "dbo.Users");
            DropIndex("dbo.UserLoginErrLogs", new[] { "UserId" });
            DropTable("dbo.UserLoginErrLogs");
            DropTable("dbo.Users");
        }
    }
}
